<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //生成器是为了防止回调地狱的
        //返回值是一个迭代器
        function* gFunc(){
          
            yield '健身健身健身';
           
            yield  '早上好';
        }
        let iter = gFunc()
        // iter.next()
        // iter.next()
        for(let key of iter){
            console.log(key);
        }
        console.log('==========================');
        let m1 = new Map()
        m1.set('001',{id:'xxx'})
        m1.set('002',{id:'yyy'})
        m1.set('003',{id:'zzz'})
        let iterKeys = m1.keys()
        for(let key of iterKeys){
            console.log(key);
        }
    </script>
</body>
</html>